(function() {
  app.config(function($stateProvider, $urlRouterProvider) {
    $stateProvider
      .state('home', {
        title: '共享策略',
        url: '/home',
        templateUrl: 'source/home/home.html',
        controller: 'homeCtrl',
        notNeedLogin: true
      })
      .state('detail', {
        title: '行情',
        url: '/detail/:type',
        params: {
          type: null
        },
        templateUrl: 'source/market/detail.html',
        controller: 'detailCtrl',
        notNeedLogin: true
      })
      .state('detail_zs', {
        title: '指数行情',
        url: '/detail_zs',
        templateUrl: 'source/market/detail_zs.html',
        controller: 'detail_zsCtrl',
        notNeedLogin: true
      })
      .state('strategy', {
        title: '创建策略',
        url: '/strategy/:type',
        params: {
          type: null
        },
        templateUrl: 'source/market/strategy.html',
        controller: 'strategyCtrl',
        notNeedLogin: false
      })
      .state('zixuan_m', {
        title: '自选管理',
        url: '/zixuan_m',
        templateUrl: 'source/market/zixuan_m.html',
        controller: 'zixuan_mCtrl',
        notNeedLogin: true
      })
      .state('top', {
        title: '榜单',
        url: '/top',
        templateUrl: 'source/market/top.html',
        controller: 'topCtrl',
        notNeedLogin: true
      })
      .state('market', {
        title: '市场',
        url: '/market',
        templateUrl: 'source/market/market.html',
        controller: 'marketCtrl',
        notNeedLogin: true
      })
      .state('market.hs', {
        title: '市场',
        url: '/market.hs',
        templateUrl: 'source/market/market-hs.html',

        controller: 'marketViewsCtrl',
        notNeedLogin: true
      })
      .state('condition', {
        title: '条件单（创建策略）',
        url: '/condition/:type',
        params: {
          type: null,
          data: null
        },
        templateUrl: 'source/market/condition.html',
        controller: 'conditionCtrl',
        notNeedLogin: true
      })
      .state('market.bk', {
        title: '市场',
        url: '/market.bk',
        templateUrl: 'source/market/market-bk.html',
        controller: 'marketViewsCtrl',
        notNeedLogin: true
      })
      .state('market.cy', {
        title: '市场',
        url: '/market.cy',
        templateUrl: 'source/market/market-cy.html',
        controller: 'marketViewsCtrl',
        notNeedLogin: true
      })
      .state('zixuan', {
        title: '自选',
        url: '/zixuan',
        templateUrl: 'source/market/zixuan.html',
        controller: 'zixuanCtrl',
        notNeedLogin: true
      })
      .state('running', {
        title: '策略执行动态',
        url: '/running/:tab_index',
        params: {
          tab_index: null
        },
        templateUrl: 'source/running/running.html',
        controller: 'runningCtrl',
        notNeedLogin: false
      })
      .state('report', {
        title: '策略回报',
        url: '/report',
        templateUrl: 'source/report/report.html',
        controller: 'reportCtrl',
        notNeedLogin: false
      })
      .state('search', {
        title: '选择股票',
        url: '/search/:type',
        params: {
          type: null
        },
        templateUrl: 'source/market/search.html',
        controller: 'searchCtrl',
        notNeedLogin: true
      })
      .state('free-search', {
        title: '选择股票',
        url: '/free-search',
        templateUrl: 'source/pc/free-search.html',
        controller: 'freeSearchCtrl',
        notNeedLogin: true
      })
      .state('free', {
        title: '选择股票',
        url: '/free',
        controller: 'freeCtrl',
        notNeedLogin: true
      })
      .state('login', {
        title: '登录',
        url: '/login/:mobile/:next',
        params: {
          mobile: null,
          next: null,
          go_to: null,
          go_to_params: null
        },
        templateUrl: 'source/login/login.html',
        controller: 'loginCtrl',
        notNeedLogin: true
      })
      .state('register', {
        title: '注册',
        url: '/register',
        templateUrl: 'source/login/register.html',
        controller: 'registerCtrl',
        notNeedLogin: true
      })
      .state('register-agree', {
        title: '注册协议',
        url: '/register-agree',
        templateUrl: 'source/login/register-agree.html',
        notNeedLogin: true
      })
      .state('register-agree-1', {
        title: '注册协议',
        url: '/register-agree-1',
        templateUrl: 'source/login/register-agree.1.html',
        notNeedLogin: true
      })
      .state('hezuo-agree', {
        title: '合作协议',
        url: '/hezuo-agree',
        params: {
          data: null,
          type: null,
        },
        templateUrl: 'source/login/hezuo-agree.html',
        controller: 'hezuo_agreeCtrl',
        notNeedLogin: true
      })
      .state('forgetpw', {
        title: '重置密码',
        url: '/forgetpw',
        templateUrl: 'source/login/forgetpw.html',
        controller: 'forgetpwCtrl',
        notNeedLogin: true
      })
      .state('novice', {
        title: '帮助',
        url: '/novice',
        templateUrl: 'source/novice/novice.html',
        controller: 'noviceCtrl',
        notNeedLogin: true
      })
      .state('yiyuan', {
        title: '一元体验',
        url: '/yiyuan',
        templateUrl: 'source/home/yiyuan.html',
        notNeedLogin: true
      })
      .state('free-wx', {
        title: '活动规则',
        url: '/free-wx',
        controller: 'freeWxCtrl',
        templateUrl: 'source/wchat/free-wx.html',
        notNeedLogin: true
      })
      .state('wx-focus', {
        title: '关注我们',
        url: '/wx-focus',
        templateUrl: 'source/wchat/wx-focus.html',
        notNeedLogin: true
      })
      .state('free-pc', {
        title: '活动规则',
        url: '/free-pc',
        controller: 'freePcCtrl',
        templateUrl: 'source/pc/free-pc.html',
        notNeedLogin: true
      })
      .state('guizhe-jpg', {
        title: '一分钟玩转共享策略',
        url: '/guizhe-jpg',
        templateUrl: 'source/novice/guizhe-jpg.html',
        notNeedLogin: true
      })
      .state('policy-apply-txt', {
        title: '申请说明',
        url: '/policy-apply-txt',
        templateUrl: 'source/novice/policy-apply-txt.html',
        notNeedLogin: true
      })
      .state('help', {
        title: '帮助',
        url: '/help',
        templateUrl: 'source/help/help.html',
        controller: 'helpCtrl',
        notNeedLogin: true
      })
      .state('safe-txt', {
        title: '安全保证',
        url: '/safe-txt',
        templateUrl: 'source/novice/safe-txt.html',
        notNeedLogin: true
      })
      .state('trade-txt', {
        title: 'A股交易规则',
        url: '/trade-txt',
        templateUrl: 'source/novice/trade-txt.html',
        notNeedLogin: true
      })
      .state('about', {
        title: '关于我们',
        url: '/about',
        templateUrl: 'source/novice/about.html',
        notNeedLogin: true
      })
      .state('details', {
        title: '执行详情',
        url: '/details',
        templateUrl: 'source/running/details.html',
        controller: 'detailsCtrl',
        notNeedLogin: true
      })
      .state('details-report', {
        title: '回报详情',
        url: '/details-report/:source',
        templateUrl: 'source/report/details-report.html',
        controller: 'details-reportCtrl',
        params: {
          source: ''
        },
        notNeedLogin: true
      })
      .state('notice_list', {
        title: '公告',
        url: '/notice_list',
        templateUrl: 'source/notice/notice_list.html',
        controller: 'notice_listCtrl',
        notNeedLogin: true
      })
      .state('notice_detail', {
        params: { notice: {} },
        title: '详情',
        url: '/notice_detail',
        templateUrl: 'source/notice/notice_detail.html',
        controller: 'notice_detailCtrl',
        notNeedLogin: true
      })
      .state('my_index', {
        title: '个人中心',
        url: '/my_index',
        templateUrl: 'source/my/my_index.html',
        controller: 'my_indexCtrl',
        notNeedLogin: false
      })
      .state('my-info', {
        title: '个人信息',
        url: '/my-info',
        templateUrl: 'source/my/my-info.html',
        controller: 'my_infoCtrl',
        notNeedLogin: true
      })
      .state('bank_m', {
        title: '银行卡管理',
        url: '/bank_m',
        templateUrl: 'source/my/bank_m.html',
        controller: 'bank_mCtrl',
        notNeedLogin: true
      })
      .state('myCondition', {
        title: '我的条件单',
        url: '/myCondition',
        template: '<div class="myCondition"><div class="myCondition-tabs"><div ng-class="{actived:current_state===it.state}" ng-repeat="it in tabs" ng-bind="it.txt" ng-click="go(it.state)"></div></div><ui-view></ui-view></div>',
        controller: function($scope, $state, $location, $rootScope) {
          console.log($rootScope.current_state)
          $scope.tabs = [
            { txt: '生效中', state: '/myCondition.running', },
            { txt: '已触发', state: '/myCondition.trigger', },
            { txt: '已失效', state: '/myCondition.invalid', },
          ];
          $scope.go = function(it) {
            $state.go(it.split('/')[1]);
            $location.replace();
          };
          $state.go('myCondition.running');
        },
        notNeedLogin: false
      })
      .state('myCondition.running', {
        url: '/myCondition.running',
        template: '<div ng-init="init()"><card-info dir-cards="dir_cards"></card-info><div class="empty-tip-vip" ng-if="!(dir_cards.data&&dir_cards.data.length>0)"><div></div><p>暂无数据</p></div></div>',
        title: '我的条件单',
        controller: 'myConditionCtrl',
        notNeedLogin: false
      })
      .state('myCondition.trigger', {
        url: '/myCondition.trigger',
        template: '<div ng-init="init()"><card-info dir-cards="dir_cards"></card-info><div class="empty-tip-vip" ng-if="!(dir_cards.data&&dir_cards.data.length>0)"><div></div><p>暂无数据 </p></div></div>',
        title: '我的条件单',
        controller: 'myConditionCtrl',
        notNeedLogin: false
      })
      .state('myCondition.invalid', {
        url: '/myCondition.invalid',
        template: '<div ng-init="init()"><card-info dir-cards="dir_cards"></card-info><div class="empty-tip-vip" ng-if="!(dir_cards.data&&dir_cards.data.length>0)"><div></div><p>暂无数据</p></div></div>',
        title: '我的条件单',
        controller: 'myConditionCtrl',
        notNeedLogin: false
      })
      .state('bank_bind', {
        title: '添加银行卡',
        url: '/bank_bind',
        templateUrl: 'source/my/bank_bind.html',
        controller: 'bank_bindCtrl',
        notNeedLogin: true
      })
      .state('payflow', {
        title: '资金流水',
        url: '/payflow',
        templateUrl: 'source/my/payflow.html',
        controller: 'payflowCtrl',
        notNeedLogin: true
      })
      .state('change_psw', {
        title: '修改密码',
        url: '/change_psw',
        templateUrl: 'source/my/change_psw.html',
        controller: 'change_pswCtrl',
        notNeedLogin: true
      })
      .state('promote', {
        title: '推广分享',
        url: '/promote',
        templateUrl: 'source/my/promote.html',
        controller: 'promoteCtrl',
        notNeedLogin: true
      })
      .state('pay', {
        title: '充值',
        url: '/pay',
        templateUrl: 'source/my/pay.html',
        controller: 'payCtrl',
        notNeedLogin: true
      })
      .state('withdraw', {
        title: '提现',
        url: '/withdraw',
        templateUrl: 'source/my/withdraw.html',
        controller: 'withdrawCtrl',
        notNeedLogin: true
      })
      .state('test', {
        title: '测试',
        url: '/test',
        templateUrl: 'source/test/test.html',
        controller: function($state) {},
        notNeedLogin: true
      })
      .state('test.mytest', {
        url: '/mytest',
        title: '子视图',
        views: {
          dd: {
            template: '<p>{{msg}}<p>',
            controller: function($scope) {
              $scope.msg = 'this is dd viewssssss';
            }
          },
          tt: {
            template: '<p>{{msg}}<p>',
            controller: function($scope) {
              $scope.msg = 'this is tt viewsss';
            }
          }
        },
        notNeedLogin: true
      })
      .state('test.hertest', {
        url: '/hertest',
        title: '子视图2',
        views: {
          dd: {
            template: '<p>{{msg}}<p>',
            controller: function($scope) {
              $scope.msg = 'this is dd viewssssss';
            }
          },
          tt: {
            template: '<p>{{msg}}<p>',
            controller: function($scope) {
              $scope.msg = 'this is tt viewsss';
            }
          }
        },
        notNeedLogin: true
      })
      .state('home_more', {
        title: '',
        url: '/home_more',
        params: { type: null },
        templateUrl: 'source/home/home-more.html',
        controller: 'home_moreCtrl',
        notNeedLogin: true
      })
      .state('vip-index', {
        title: '',
        url: '/vip-index',
        templateUrl: 'source/vip/index.html',
        controller: 'vipIndexCtrl',
        notNeedLogin: true
      })
      .state('vip-property', {
        title: '账户资产',
        url: '/vip-property',
        templateUrl: 'source/vip/vip-property.html',
        controller: 'vipPropertyCtrl',
        notNeedLogin: true
      })
      .state('vip-trade', {
        title: '交易',
        url: '/vip-trade/:type/:stkcode/:market',
        params: {
          type: null,
          stkcode: null,
          market: null
        },
        templateUrl: 'source/vip/vip-trade.html',
        controller: 'vipTradeCtrl',
        notNeedLogin: true
      })
      .state('vip-cancel', {
        title: '撤单',
        url: '/vip-cancel',
        templateUrl: 'source/vip/vip-cancel.html',
        controller: 'vipCancelCtrl',
        notNeedLogin: true
      })
      .state('vip-hold', {
        title: '我的持仓',
        url: '/vip-hold',
        templateUrl: 'source/vip/vip-hold.html',
        controller: 'vipHoldCtrl',
        notNeedLogin: true
      })
      .state('vip-deal-query', {
        title: '成交查询',
        url: '/vip-deal-query',
        templateUrl: 'source/vip/vip-deal-query.html',
        controller: 'vipDealQueryCtrl',
        notNeedLogin: true
      })
      .state('vip-entrust-query', {
        title: '委托查询',
        url: '/vip-entrust-query',
        templateUrl: 'source/vip/vip-entrust-query.html',
        controller: 'vipEntrustQueryCtrl',
        notNeedLogin: true
      })
      .state('vip-deposit', {
        title: '追加保证金',
        url: '/vip-deposit/:contract_id',
        templateUrl: 'source/vip/vip-deposit.html',
        params: {
          contract_id: null,
        },
        controller: 'vipDepositCtrl',
        notNeedLogin: true
      })
      .state('vip-profit', {
        title: '提取盈利',
        url: '/vip-profit/:contract_id',
        templateUrl: 'source/vip/vip-profit.html',
        controller: 'vipProfitCtrl',
        params: {
          contract_id: null,
        },
        notNeedLogin: true
      })
      .state('vip-payflow', {
        title: '资金流水',
        url: '/vip-payflow',
        templateUrl: 'source/vip/vip-payflow.html',
        controller: 'vipPayflowCtrl',
        notNeedLogin: true
      });
    $urlRouterProvider.otherwise('/home');
  });
})();